{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "tb_Waveform.ipynb",
      "provenance": [],
      "collapsed_sections": [],
      "authorship_tag": "ABX9TyMNxShBqYXxQ0C+QP4RDllA",
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/ThePituLegend/py4hw/blob/main/tests/tb_Waveform.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "a_641TOCZHou"
      },
      "source": [
        "#Config and imports"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "l-S4df8UR3s2"
      },
      "source": [
        "*Notebook* settings (for more than one graph per cell):"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "grLlwCEsd1uT"
      },
      "source": [
        "from IPython.core.interactiveshell import InteractiveShell\n",
        "InteractiveShell.ast_node_interactivity = 'all'"
      ],
      "execution_count": 1,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "GjHca5RJR5Ua"
      },
      "source": [
        "Load *nbwavedrom* library:"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "0a9d1SBD9Qa4"
      },
      "source": [
        "!pip install nbwavedrom\n",
        "from nbwavedrom import draw"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "J0iC0IYtR_P1"
      },
      "source": [
        "Load *Py4Hw* library:"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "0Hu1-6yPZYEe"
      },
      "source": [
        "#!pip install py4hw #For release version\n",
        "!git clone https://github.com/davidcastells/py4hw.git # for dev version\n",
        "%cd py4hw\n",
        "from py4hw import *"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "EqApQ4HLf1kv"
      },
      "source": [
        "# Test"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "0kIVCy-lf09A"
      },
      "source": [
        "sys = HWSystem()\n",
        "\n",
        "a = sys.wire(\"a\", 3)\n",
        "r = sys.wire(\"r\", 3)\n",
        "p = sys.wire(\"p\", 3)\n",
        "\n",
        "vcc = sys.wire('one', 1)\n",
        "Constant(sys, 'one', 1, vcc)\n",
        "\n",
        "Add(sys, \"add\", a,p, r)\n",
        "Reg(sys, \"reg\", r, vcc, p)\n",
        "\n",
        "Constant(sys, \"a\", 1, a)\n",
        "\n",
        "Waveform(sys, \"a\", a)\n",
        "Waveform(sys, \"p\", p)\n",
        "Waveform(sys, \"r\", r)\n",
        "\n",
        "sim = Simulator(sys)\n",
        "\n",
        "sim.clk(20)\n",
        "\n",
        "draw(sim.get_waveform(\"Serial Add\"))"
      ],
      "execution_count": null,
      "outputs": []
    }
  ]
}